<!DOCTYPE html>
<html>
	<head>
	  <title>Blog</title>
	  <%= stylesheet_link_tag    "application", :media => "all" %>
	  <%= javascript_include_tag "application" %>
	  <%= csrf_meta_tags %>
	</head>
	
	<script language = "javascript">
		function timemachine() {

			var date = new Date;
			var hours = date.getHours();
 			var minutes = date.getMinutes();
			var seconds = date.getSeconds();

			var period = "AM";

			if (hours > 11){
				period = "PM";
				hours = hours - 12;
			}
			
			if (hours < 10) hours = "0"+hours;
			if (minutes < 10) minutes = "0"+minutes;
			if (seconds < 10) seconds = "0"+seconds;

			t = hours+":"+minutes+":"+seconds;
			document.getElementById("time").innerHTML = t;
			setTimeout("timemachine()", 1000);
		}	
	</script>

	
	
	<body style="background: #EEEEEE;" onload = "timemachine() " >
		<div class="page-wrap">
			<div class="header">
				<center><h1>WELCOME</h1></center>
			</div><br/>
			
			<div class="main_block">
				<div class="navbar">
					<ul class="cssmenu dropdown">
						<li><%= link_to "Home", '/' , :class => 'button button_left' %></li>
						<% if session[:user] != nil %>
						<li><%= link_to "Posts", posts_path, :class => 'button button_left' %></li>
						<li><%= link_to "Events", events_path, :class => 'button button_left' %></li>
						<% if session[:user].authority == 'admin' %>
						<li><%= link_to "Users", users_path, :class => 'button button_left' %></li>
						<% end %>
						<li><a class="button button_left">My Account</a>
							<ul class="cssmenu sub-menu">
								<li><%= link_to "My Profile", '/users/'+session[:user].id.to_s%></li>
								<li><%= link_to "Change Password", change_password_path%></li>
								<li><%= link_to "Log Out", logout_path%></li>
							</ul>
						</li>
						<% else %>
						<li><%= link_to "Log In", login_path, :class => 'button button_left' %></li>
						<li><%= link_to "Sign Up", signup_path, :class => 'button button_left' %></li>
						<% end %>
					</ul>
					<div id = "time" style="float: right; color: white;"></div>
					<% if session[:user] != nil %>
						<br/><div style="color: white; float: right">Hello <%= session[:user].first_name %></div>
					<% end %>
				</div>
				
				<div class="main_body">
					<div class="inner_body">
						<%= yield %>
					</div>
				</div>
			</div>
		</div>

	</body>
</html>
